package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.ModePayment;
import com.lrkj.payfee.service.IModePaymentService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 收款方式Controller
 *
 * @author yajun_ren
 * @date 2021-08-06
 */
@RestController
@RequestMapping("/payfee/modePayment")
public class ModePaymentController extends BaseController
{
    @Autowired
    private IModePaymentService modePaymentService;

    /**
     * 查询收款方式列表
     */
    @ApiOperation(value = "查询收款方式列表", notes = "查询收款方式列表")
    @GetMapping("/list")
    public TableDataInfo list(ModePayment modePayment)
    {
        startPage();
        List<ModePayment> list = modePaymentService.selectModePaymentList(modePayment);
        return getDataTable(list);
    }

    /**
     * 导出收款方式列表
     */
	@ApiOperation(value = "导出收款方式列表", notes = "导出收款方式列表")
    @PreAuthorize("@ss.hasPermi('payfee:modePayment:export')")
    @Log(title = "收款方式", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ModePayment modePayment)
    {
        List<ModePayment> list = modePaymentService.selectModePaymentList(modePayment);
        ExcelUtil<ModePayment> util = new ExcelUtil<ModePayment>(ModePayment.class);
        return util.exportExcel(list, "收款方式数据");
    }

    /**
     * 获取收款方式详细信息
     */
	@ApiOperation(value = "获取收款方式详细信息", notes = "获取收款方式详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:modePayment:query')")
    @GetMapping(value = "/{modePaymentId}")
    public AjaxResult getInfo(@PathVariable("modePaymentId") String modePaymentId)
    {
        return AjaxResult.success(modePaymentService.selectModePaymentById(modePaymentId));
    }

    /**
     * 新增收款方式
     */
	  @ApiOperation(value = "新增收款方式", notes = "新增收款方式")
    @PreAuthorize("@ss.hasPermi('payfee:modePayment:add')")
    @Log(title = "收款方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModePayment modePayment)
    {
        return toAjax(modePaymentService.insertModePayment(modePayment));
    }

    /**
     * 修改收款方式
     */
	 @ApiOperation(value = "修改收款方式", notes = "修改收款方式")
    @PreAuthorize("@ss.hasPermi('payfee:modePayment:edit')")
    @Log(title = "收款方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModePayment modePayment)
    {
        return toAjax(modePaymentService.updateModePayment(modePayment));
    }

    /**
     * 删除收款方式
     */
	 @ApiOperation(value = "删除收款方式", notes = "删除收款方式")
    @PreAuthorize("@ss.hasPermi('payfee:modePayment:remove')")
    @Log(title = "收款方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{modePaymentIds}")
    public AjaxResult remove(@PathVariable String[] modePaymentIds)
    {
        return toAjax(modePaymentService.deleteModePaymentByIds(modePaymentIds));
    }
}
